package com.sc.study.exam.service.impl;

import java.util.List;

import com.sc.study.exam.domain.ScTest;
import com.sc.study.exam.mapper.ScQuestionMapper;
import com.sc.study.exam.mapper.ScTestMapper;
import com.sc.study.exam.mapper.ScTestexamMapper;
import com.sc.study.exam.service.IScQuestionService;
import com.sc.study.exam.service.IScTestexamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sc.study.exam.mapper.ScTestexamQuestionMapper;
import com.sc.study.exam.domain.ScTestexamQuestion;
import com.sc.study.exam.service.IScTestexamQuestionService;

/**
 * 考试题目Service业务层处理
 * 
 * @author sc
 * @date 2022-02-27
 */
@Service
public class ScTestexamQuestionServiceImpl implements IScTestexamQuestionService 
{
    @Autowired
    private ScTestexamQuestionMapper scTestexamQuestionMapper;

    @Autowired
    private ScQuestionMapper scQuestionMapper;

    @Autowired
    private ScTestexamMapper scTestexamMapper;


    @Autowired
    private ScTestMapper scTestMapper;



    /**
     * 查询考试题目
     * 
     * @param id 考试题目主键
     * @return 考试题目
     */
    @Override
    public ScTestexamQuestion selectScTestexamQuestionById(Long id)
    {
        return scTestexamQuestionMapper.selectScTestexamQuestionById(id);
    }

    /**
     * 查询考试题目列表
     * 设置考试对象， 题目对象
     * @param scTestexamQuestion 考试题目
     * @return 考试题目
     */
    @Override
    public List<ScTestexamQuestion> selectScTestexamQuestionList(ScTestexamQuestion scTestexamQuestion)
    {
        List<ScTestexamQuestion> scTestexamQuestions = scTestexamQuestionMapper.selectScTestexamQuestionList(scTestexamQuestion);

        //设置考试对象， 题目对象
        scTestexamQuestions.forEach(item -> {
            item.setScTest(scTestMapper.selectScTestById(item.getTestexamid()));
            item.setScQuestion(scQuestionMapper.selectScQuestionById(item.getQuestionid()));
        });


        return scTestexamQuestions;
    }

    /**
     * 新增考试题目
     * 
     * @param scTestexamQuestion 考试题目
     * @return 结果
     */
    @Override
    public int insertScTestexamQuestion(ScTestexamQuestion scTestexamQuestion)
    {
        return scTestexamQuestionMapper.insertScTestexamQuestion(scTestexamQuestion);
    }

    /**
     * 修改考试题目
     * 
     * @param scTestexamQuestion 考试题目
     * @return 结果
     */
    @Override
    public int updateScTestexamQuestion(ScTestexamQuestion scTestexamQuestion)
    {
        return scTestexamQuestionMapper.updateScTestexamQuestion(scTestexamQuestion);
    }

    /**
     * 批量删除考试题目
     * 
     * @param ids 需要删除的考试题目主键
     * @return 结果
     */
    @Override
    public int deleteScTestexamQuestionByIds(Long[] ids)
    {
        return scTestexamQuestionMapper.deleteScTestexamQuestionByIds(ids);
    }

    /**
     * 删除考试题目信息
     * 
     * @param id 考试题目主键
     * @return 结果
     */
    @Override
    public int deleteScTestexamQuestionById(Long id)
    {
        return scTestexamQuestionMapper.deleteScTestexamQuestionById(id);
    }

    /**
     * 批量新增
     * @param scTestexamQuestionList
     * @return
     */
    @Override
    public int batchAdd(ScTestexamQuestion[] scTestexamQuestionList) {
        return scTestexamQuestionMapper.batchAdd(scTestexamQuestionList);
    }


}
